home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / usr / include / sys / msg.h.z / msg.h
C/C++ Source or Header  |  1992-04-03  |  4KB  |  153 lines

  1. /*
  2.  * msg.h --
  3.  *
  4.  *     header for msg(2)
  5.  *
  6.  *
  7.  * Copyright 1990, Silicon Graphics, Inc. 
  8.  * All Rights Reserved.
  9.  *
  10.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  11.  * the contents of this file may not be disclosed to third parties, copied or 
  12.  * duplicated in any form, in whole or in part, without the prior written 
  13.  * permission of Silicon Graphics, Inc.
  14.  *
  15.  * RESTRICTED RIGHTS LEGEND:
  16.  * Use, duplication or disclosure by the Government is subject to restrictions 
  17.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  18.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or 
  19.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - 
  20.  * rights reserved under the Copyright Laws of the United States.
  21.  */
  22. /*    Copyright (c) 1984 AT&T    */
  23. /*      All Rights Reserved      */
  24.  
  25. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T    */
  26. /*    The copyright notice above does not evidence any       */
  27. /*    actual or intended publication of such source code.    */
  28.  
  29. #ifndef __SYS_MSG_H__
  30. #define __SYS_MSG_H__
  31.  
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35.  
  36. #ident    "$Revision: 3.12 $"
  37.  
  38. /*
  39. **    IPC Message Facility.
  40. */
  41.  
  42. /*
  43. **    Implementation Constants.
  44. */
  45. #ifdef _KERNEL
  46. #define    PMSG    (PZERO + 2)    /* message facility sleep priority */
  47. #endif /* _KERNEL */
  48.  
  49. /*
  50. **    Permission Definitions.
  51. */
  52.  
  53. #define    MSG_R    0400    /* read permission */
  54. #define    MSG_W    0200    /* write permission */
  55.  
  56. /*
  57. **    Message Operation Flags.
  58. */
  59.  
  60. #define    MSG_NOERROR    010000    /* no error if big message */
  61.  
  62. /*
  63. **    Structure Definitions.
  64. */
  65.  
  66. /*
  67. **    There is one msg queue id data structure for each q in the system.
  68. */
  69.  
  70. struct msqid_ds {
  71.     struct ipc_perm    msg_perm;    /* operation permission struct */
  72.     struct msg    *msg_first;    /* ptr to first message on q */
  73.     struct msg    *msg_last;    /* ptr to last message on q */
  74.     ushort        msg_cbytes;    /* current # bytes on q */
  75.     ushort        msg_qnum;    /* # of messages on q */
  76.     ushort        msg_qbytes;    /* max # of bytes on q */
  77.     ushort        msg_lspid;    /* pid of last msgsnd */
  78.     ushort        msg_lrpid;    /* pid of last msgrcv */
  79.     time_t        msg_stime;    /* last msgsnd time */
  80.     time_t        msg_rtime;    /* last msgrcv time */
  81.     time_t        msg_ctime;    /* last change time */
  82. };
  83.  
  84.  
  85. /*
  86. **    User message buffer template for msgsnd and msgrecv system calls.
  87. */
  88.  
  89. struct msgbuf {
  90.     long    mtype;        /* message type */
  91.     char    mtext[1];    /* message text */
  92. };
  93.  
  94. /*
  95. **    Message information structure.
  96. */
  97.  
  98. struct msginfo {
  99.     int    msgmax,    /* max message size */
  100.         msgmnb,    /* max # bytes on queue */
  101.         msgmni,    /* # of message queue identifiers */
  102.         msgssz,    /* msg segment size (should be word size multiple) */
  103.         msgtql;    /* # of system message headers */
  104.     ushort    msgseg;    /* # of msg segments (MUST BE < 32768) */
  105. };
  106.  
  107. #ifdef _KERNEL
  108. /*    Each message queue is locked with its own semaphore,
  109. **    and has its own readers/writers waiting semaphore.
  110. **    We cannot add anything to the msqid_ds structure since
  111. **    this is used in user programs and any change would break
  112. **    object file compatibility.  Therefore, we allocate a
  113. **    parallel array, msglock, which contains the message queue
  114. **    locks and semaphores. The array is defined in the msg master
  115. **    file. The following macro takes a pointer to the message
  116. **    queue and returns its corresponding semaphore structure entry.
  117. **/
  118.  
  119. #define    MSGADDR(X)    msgsem[X]
  120.  
  121. struct msgsem {
  122.     sema_t    msg_lock;    /* lock for msqid_ds structure */
  123.     sema_t    msg_rwait;    /* to wait to read a msg */
  124.     sema_t    msg_wwait;    /* to wait to write a msg */
  125. };
  126.  
  127. /*
  128. **    There is one msg structure for each message that may be in the system.
  129. */
  130.  
  131. struct msg {
  132.     struct msg    *msg_next;    /* ptr to next message on q */
  133.     long        msg_type;    /* message type */
  134.     short        msg_ts;        /* message text size */
  135.     caddr_t        msg_spot;    /* message text map address */
  136. };
  137. #endif /* _KERNEL */
  138.  
  139. #ifndef _KERNEL
  140.  
  141. extern int    msgctl(int, int, ...);
  142. extern int    msgget(key_t, int);
  143. extern int    msgrcv(int, struct msgbuf *, int, long, int);
  144. extern int    msgsnd(int, const struct msgbuf *, int, int);
  145.  
  146. #endif /* !_KERNEL */
  147.  
  148. #ifdef __cplusplus
  149. }
  150. #endif
  151.  
  152. #endif /* !__SYS_MSG_H__ */
  153.